package com.softer.wxzj.controller;/**
 * @author Gong Zhiyang
 * @date 2019/6/26
 */

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.BaseBankInfo;
import com.softer.wxzj.entity.BaseContractorBankInfo;
import com.softer.wxzj.service.BaseContractorBankInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 承办银行
 *
 * @author Gong Zhiyang
 * @date 2019/6/26
 */
@RestController
@RequestMapping("/baseContractorBank")
@Slf4j
public class BaseContractorBankInfoController {
    @Autowired
    private BaseContractorBankInfoService baseContractorBankInfoService;

    /**
     * 新增承办银行
     *
     * @param baseContractorBankInfo 承办银行信息
     * @return 新增结果
     */
    @RequestMapping("/add")
    @LogRecord(description = "新增承办银行", operationUnit = LogOperationUnit.BASE_CONTRACTOR_BANK_INFO, operationType = LogOperationType.INSERT)
    public CommonResult add(BaseContractorBankInfo baseContractorBankInfo) {
        return baseContractorBankInfoService.insert(baseContractorBankInfo);
    }

    /**
     * 修改承办银行
     *
     * @param baseContractorBankInfo 承办银行信息
     * @return 修改结果
     */
    @RequestMapping("/update")
    @LogRecord(description = "修改承办银行", operationUnit = LogOperationUnit.BASE_CONTRACTOR_BANK_INFO, operationType = LogOperationType.UPDATE)
    public CommonResult update(BaseContractorBankInfo baseContractorBankInfo) {
        return baseContractorBankInfoService.update(baseContractorBankInfo);
    }

    /**
     * 查询承办银行详情
     *
     * @param id 承办银行ID
     * @return 承办银行详情
     */
    @RequestMapping("/detail")
    @LogRecord(description = "查询承办银行详情", operationUnit = LogOperationUnit.BASE_CONTRACTOR_BANK_INFO, operationType = LogOperationType.UPDATE)
    public BaseContractorBankInfo detail(String id) {
        return baseContractorBankInfoService.getInfo(id);
    }

    /**
     * 删除承办银行详情
     *
     * @param id 承办银行ID
     * @return 删除结构
     */
    @RequestMapping("/delete")
    @LogRecord(description = "查询承办银行详情", operationUnit = LogOperationUnit.BASE_CONTRACTOR_BANK_INFO, operationType = LogOperationType.UPDATE)
    public CommonResult delete(String id) {
        return baseContractorBankInfoService.delete(id);
    }

    /**
     * 查询承办银行下拉列表
     *
     * @return 承办银行列表
     */
    @RequestMapping("/getAllList")
    @LogRecord(description = "查询承办银行下拉列表", operationUnit = LogOperationUnit.BASE_CONTRACTOR_BANK_INFO, operationType = LogOperationType.SELECT)
    public List<BaseBankInfo> getAllList() {
        return baseContractorBankInfoService.getAllList();
    }

    /**
     * 查询承办银行列表
     *
     * @param page                   分页实体
     * @param baseContractorBankInfo 查询实体
     * @param fuzzy                  模糊查询字段
     * @return 承办银行列表
     */
    @RequestMapping("/getList")
    @LogRecord(description = "查询承办银行列表", operationUnit = LogOperationUnit.BASE_CONTRACTOR_BANK_INFO, operationType = LogOperationType.SELECT)
    public PageInfo<BaseContractorBankInfo> getList(Page page, BaseContractorBankInfo baseContractorBankInfo, String fuzzy) {
        return baseContractorBankInfoService.getList(page, baseContractorBankInfo,fuzzy);
    }
    /**
     * 通过登录人查看银行id
     *
     */
    @RequestMapping("/getAllListSelect")
    @LogRecord(description = "通过登录人查看银行id", operationUnit = LogOperationUnit.ACC_KEEP_ACCOUNT, operationType = LogOperationType.SELECT)
    public List<BaseBankInfo> getAllListSelect(){
        return baseContractorBankInfoService.getAllListSelect();
    }
}
